*===================================================================================*
* Ado-file: 	csxmcmdast Version 1.0 
* Author: 		Chen Shao(陈志豪)
* Affiliation: 	Lanzhou University
* E-mail: 		chenzhh20@lzu.edu.cn
* License:      Mulan PSL v2
* Date: 		2025/5/12                                 
*===================================================================================*

capture program drop csxmaihlp
program define csxmaihlp
	syntax [anything]
    if c(os) != "Windows" {
		di as error "只开发了Windows版本的命令"
		exit
	}
	di in blue "晨韶学妹向您报告："
	*Step1 判断
	if "`anything'" == ""{
		di as error "输入不能为空值哦,点击查看help文档:"
		di in white "{help csxmaihlp}"
		exit
	}
	
	capture findfile "`anything'.sthlp"
	if _rc == 0{
		qui findfile "`anything'.sthlp"
		local hlpnm "`anything'.sthlp"
	}
	else{
		capture findfile "`anything'.hlp"
		if _rc==0{
		qui findfile "`anything'.hlp"
		local hlpnm "`anything'.hlp"
		}
		else {
			capture which "`anything'"
			if _rc==0{
				di as error "请您输入该命令的全名"
			}
			else {
				di as error "找不到该命令"
			}
			di "{help `anything':点击查找}"
			exit
		}
	}
	
	*Step2：Shell操作
	local hlpadr `r(fn)'
	local hlpadr= subinstr("`hlpadr'", "/", "\", .)
	local pwds `c(pwd)'
	shell ///
	copy "`hlpadr'" "`pwds'" & ///复制文件到默认路径
	yes & ///覆盖原有文件(若有)
	cd "`pwds'" & ///修改指定路径为stata默认路径
	del "HelpFile.txt" & ///删除原有文档
	ren "`hlpnm'" "HelpFile.txt" & ///改名
	yes & ///
	echo "`pwds'\HelpFile.txt" |clip ///复制文件地址
	
	**Step3：输出
	di in white "{hline 60}"
	di in white "该命令的帮助文档已储存为 `pwds'\HelpFile.txt ;"
	di in white "该路径也自动储存在您的粘贴板上;"
	di in white "{hline 60}"
	di in white "以下是一些常用的AI网站链接："
	di `"{browse "https://chat.deepseek.com/": DeepSeek }"'
	di `"{browse "https://kimi.moonshot.cn/": Kimi }"'
	di `"{browse "https://zhida.zhihu.com/": 知乎直答 }"'
	di `"{browse "https://chatglm.cn/": 智谱清言 }"'
	di `"{browse "https://yiyan.baidu.com/": 文心一言 }"'
	di `"{browse "https://baoyueai.com/": 包阅AI }"'
	di in white "{hline 60}"
	di in blue "您布置的任务已经完成，请您过目~♥"
end